package com.czl.module_storehouse.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.czl.base.data.bean.tengyun.SortBean;
import com.czl.module_storehouse.R;

import java.util.List;

/**
 * @author xubin
 */
public class RemandInfoAdapter extends BaseQuickAdapter<SortBean, BaseViewHolder> {
    public static final int TAG_RECEIVE = 1;
    public static final int TAG_BORROW = 2;
    private final int type;

    public RemandInfoAdapter(int layoutResId, int type) {
        super(layoutResId);
        this.type = type;
    }

    public RemandInfoAdapter(int layoutResId, @Nullable List<SortBean> data, int type) {
        super(layoutResId, data);
        this.type = type;
    }


    private String getRemandType(int type) {
        if (TAG_RECEIVE == type) {
            return "已领：";
        } else {
            return "已借：";
        }
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, SortBean item) {
        baseViewHolder.setText(R.id.tv_title, item.getSortName())
                .setText(R.id.tv_model, "型号：" + item.getSortModel())
                .setText(R.id.tv_num, "数量：" + (item.applyNum()))
                .setText(R.id.text_type, getRemandType(type))
                .setText(R.id.tv_act_num, String.valueOf(item.lendNum()))
                .setText(R.id.tv_return_num, String.valueOf(item.returnNum()))
                .setText(R.id.tv_intact_num, "完好：" + item.intactNum())
                .setText(R.id.tv_damage_num, "损坏：" + item.damageNum());
    }
}
